<template>
    <div style="width:100%;height:100%;" id="data_source_con"></div>
</template>

<script>
import echarts from 'echarts';
import $http from '../../../utils/axiosWrap';

export default {
    name: 'dataSourcePie',
    data () {
        return {
            aitcLockAmount: '',
            aitcUnlockAmount: ''
        };
    },
    mounted () {
        let _this = this
        $http.get('backgroundIntoLockAccount/getTodayPlatformAccount').then(function (res) {
            _this.aitcLockAmount = res.result.usdTopUpAmount / 1
            _this.aitcUnlockAmount = res.result.usdExtractAmount / 1

            _this.$nextTick(() => {
                var dataSourcePie = echarts.init(document.getElementById('data_source_con'));
                const option = {
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b} : {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'right',
                        data: ['USDI充值', 'USDI提现']
                    },
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: '66%',
                            center: ['50%', '60%'],
                            data: [
                                {value: _this.aitcLockAmount, name: 'USDI充值', itemStyle: {normal: {color: '#9bd598'}}},
                                {value: _this.aitcUnlockAmount, name: 'USDI提现', itemStyle: {normal: {color: '#ffd58f'}}}
                            ],
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };
                dataSourcePie.setOption(option);
                window.addEventListener('resize', function () {
                    dataSourcePie.resize();
                });
            });
        })
    }
};
</script>
